<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点我抽奖</button>
    <button>点我抽奖</button>
    <button>点我抽奖</button>
    <button>点我抽奖</button>
    <button>点我抽奖</button>
    <script>
        var arr = ['再接再厉','谢谢回顾','宝马一辆','再来一次','特斯拉新能源']
        var btns = document.querySelectorAll('button')
        for(var i = 0;i<arr.length;i++){
            btns[i].index = i;
            console.log(btns[i].index)
            btns[i].onclick = function(){
                // innerHTML 操纵元素写法
                this.innerHTML = arr[this.index]
                console.log(this.innerHTML)

                // innerText 操纵元素写法
                // this.innerText = arr[this.index]
                // console.log(this.innerText)

                console.log(arr[this.index])
            }
        }
        
       
    </script>    
</body>
</html>